backend: cmd: Add unit test for buildHeadlampCFG configuration mapping#6121
backend: cmd: Add unit test for buildHeadlampCFG configuration mapping#6121CygnusMaximillian wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: CygnusMaximillian The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
Adds initial unit test coverage for buildHeadlampCFG (backend/cmd), which maps config.Config values into headlampconfig.HeadlampCFG.
Changes:
- Adds
backend/cmd/server_config_test.gowithTestBuildHeadlampCFGto validate basic config-to-runtime mapping.
illume
left a comment
There was a problem hiding this comment.
Thanks for this PR.
The open review comments from Copilot still need attention — can you have a look? Once addressed, please mark them as resolved.
Signed-off-by: CygnusMaximillian <dprajjwal11@gmail.com>
4d26a60 to
70da609
Compare
|
@illume I have resolved the changes can you please take a look |
| func TestBuildHeadlampCFG(t *testing.T) { | ||
| conf := &config.Config{ | ||
| Port: 4444, | ||
| InsecureSsl: true, | ||
| ProxyURLs: "http://proxy1,http://proxy2", | ||
| } | ||
| store := kubeconfig.NewContextStore() | ||
|
|
||
| headlampCFG := buildHeadlampCFG(conf, store) | ||
|
|
||
| assert.Equal(t, uint(4444), headlampCFG.Port) | ||
| assert.True(t, headlampCFG.Insecure) | ||
| assert.Equal(t, []string{"http://proxy1", "http://proxy2"}, headlampCFG.ProxyURLs) | ||
| assert.Equal(t, store, headlampCFG.KubeConfigStore) | ||
| } |
Summary
The buildHeadlampCFG function in backend/cmd/server.go maps raw configuration inputs into the HeadlampCFG struct. This crucial mapping logic currently has no test coverage. Introducing an isolated unit test for this function will ensure configuration flags map correctly.
PR description
Introduces test coverage for buildHeadlampCFG in the cmd package to ensure configuration fields map securely and correctly.
Changes:
Added backend/cmd/server_config_test.go with TestBuildHeadlampCFG Steps to
Test: